home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / inetray / generr.c < prev    next >
C/C++ Source or Header  |  1993-08-17  |  2KB  |  88 lines

  1. /*======================================================================
  2.                     G E N E R R . C 
  3.                     doc: Tue Jul 20 10:48:03 1993
  4.                     dlm: Tue Aug 17 09:55:01 1993
  5.                     (c) 1993 ant@bernina.ethz.ch
  6.                     uE-Info: 18 6 T 0 0 72 2 2 8 ofnI
  7. ======================================================================*/
  8.  
  9. /*#define        FOREGROUND            /* Don't fork */
  10.  
  11. #include    <stdio.h>
  12. #include    <syslog.h>
  13. #include    <fcntl.h>
  14. #include    <signal.h>
  15. #include    <sys/ioctl.h>
  16. #ifndef TIOCNOTTY
  17. #include    <termios.h>
  18. #endif
  19. #include    "version.h"
  20. #include    "patchlevel.h"
  21. #include    "config.h"
  22. #include    "common.h"
  23. #include    "stderr.h"
  24.  
  25. main(ac,av)
  26. int ac; char *av[];
  27. {
  28.     int i;
  29.     
  30.     fprintf(stderr,"%s [%s%d]\n",av[0],VERSION,PATCHLEVEL);
  31. #ifdef NOSYSLOG_QUIRK
  32.     fprintf(stderr,"\tMessages in file %s%s\n",_P_tmpdir,NOSYSLOG);
  33. #else
  34.     fprintf(stderr,"\tMessages in syslog(3)\n");
  35. #endif
  36. #ifdef NOASYNCIO_QUIRK
  37.     fprintf(stderr,"\tStderr redirection files in directory %s\n",
  38.             _P_tmpdir);
  39. #else
  40.     fprintf(stderr,"\tStderr ditto\n");
  41. #endif
  42.     fprintf(stderr,"\tStdout on Console\n");
  43.  
  44.     OPENLOG(av[0]);
  45.     
  46. #ifndef FOREGROUND
  47.     if (fork() == 0) {
  48. #endif
  49.         for (i = 0 ; i < 20; i++)
  50.             (void) close(i);
  51. #ifdef O_NOCTTY
  52.         i = open("/dev/console",O_WRONLY|O_NOCTTY);
  53. #else
  54.         i = open("/dev/console",O_WRONLY);
  55. #endif
  56.         (void) dup2(i,1);
  57.         (void) dup2(i,2);
  58.         printf("Stdout of %s [%s%d]\n",av[0],VERSION,PATCHLEVEL);
  59.             
  60. #ifndef KEEPTTY_QUIRK
  61.         i = open("/dev/tty",O_WRONLY);
  62.         if (i >= 0) {
  63.             (void) ioctl(i, TIOCNOTTY, (char *)NULL);
  64.             (void) close(i);
  65.         }
  66. #endif
  67.         if (openStderr(av[0]) < 0) exit(1);
  68. #ifndef FOREGROUND
  69.         if (fork() == 0) {
  70.             signal(SIGIO,SIG_IGN);
  71. #endif
  72.             SYSLOG(LOG_NOTICE,"syslog of %s [%s%d]",av[0],VERSION,PATCHLEVEL);
  73.             fprintf(stderr,"Stderr of %s [%s%d]\n",av[0],VERSION,PATCHLEVEL);
  74. #ifndef FOREGROUND
  75.             exit(0);
  76.         }
  77.         wait(NULL);
  78. #endif
  79.         closeStderr();
  80.         CLOSELOG();
  81. #ifndef FOREGROUND
  82.         exit(0);
  83.     }
  84.     wait(NULL);
  85. #endif
  86.     exit(0);
  87. }
  88.